package share

import (
	"fmt"
	"jgt-oper/src/bll"
	"jgt-oper/src/context"
)

// User 用户管理
type User struct {
	UserBll *bll.User `inject:""`
}

// Get 获取用户信息
func (a *User) Get(ctx *context.Context) error {
	item, err := a.UserBll.Get(ctx.Param("id"))
	if err != nil {
		return ctx.ResErrInternalServer(err)
	} else if item == nil {
		return ctx.ResErrBadRequest(fmt.Errorf("无效的用户"))
	}

	info := make(map[string]interface{})
	info["nickname"] = item.Nickname
	info["gender"] = item.Gender
	info["post"] = item.Post
	info["auth_status"] = item.AuthStatus
	info["photo"] = item.Photo

	return ctx.ResSuccess(info)
}
